﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microhard.Protal.Models;
using FluentValidation;

namespace Microhard.Protal.Validators
{
    public class CategoryModelValidator : AbstractValidator<CategoryModel>
    {
        public CategoryModelValidator()
        {
            RuleSet("Insert", () =>
            {
                RuleFor(u => u.Name).NotEmpty().WithMessage("请填写类别名称").When(r=>r.CategoryID == Guid.Empty);
            });

            RuleSet("Update", () =>
            {
                RuleFor(u => u.Name).NotEmpty().WithMessage("请填写类别名称");
            });

            RuleSet("Delete", () =>
            {

            });
        }
    }
}
